package car.slyc.service;

import car.slyc.dao.UserMapper;
import car.slyc.model.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class UserServiceImpl  {

    @Resource
    private UserMapper userMapper;



    // 登录
    public User getByUsername(String username){
        System.out.println(username);

        return  userMapper.getByUsername(username);

    }

    // 角色登录
    public User getByUsernametype(String username,String type){
        System.out.println(username);
        System.out.println(type);

        return  userMapper.getByUsernametype(username,type);

    }


    //  查询所有   模糊查询
    public List<User> getall(String name) {
        if (name.equals("0")){
            name="";
            return userMapper.getAll(name);
        }else{
            return userMapper.getAll(name);
        }
    }

    //   根据角色查找用户
    public List<User> getallBytype(String name,String type) {
        if (name.equals("0")){
            name="";
            return userMapper.getAllBytype(name,type);
        }else{
            return userMapper.getAllBytype(name,type);
        }
    }





    //    根据id查询
    public User getById(String id) {

        return userMapper.getById(id);
    }

    // 添加
    public void add(User user) {

        userMapper.add(user);
    }


    //  修改
    public int update (  User user ) {

     return    userMapper.Update(user);
    }



    //   state 修改
    public int update_state (  String id,String state ) {
    return     userMapper.Update_state(id,state);
    }



    //   state 修改
    public int update_shzt (  String id,String shzt ) {

        return     userMapper.Update_shzt(id,shzt);
    }




    //  删除
    public int del(String id) {

      return   userMapper.Del(id);
    }


    //  批量删除
    public int dels(String id) {
        return userMapper.Dels(id);
    }


}
